using System;
using System.Collections.Generic;

namespace com.tc.assistance.entity.device
{

public class GeneralDevice {

	string id;
	string name;
	string type;
	bool fixedType;


	public bool isFixedType() {

		return fixedType;
	}

	public void setFixedType(bool fixedType) {
		this.fixedType = fixedType;
	}

	public string getType() {
		return type;
	}

	public void setType(string type) {
		this.type = type;
	}

	public string getName() {
		return name;
	}

	public void setName(string name) {
		this.name = name;
	}

	string ownerId;
	List<string> supportedChannel;

    public List<string> getSupportedChannel()
    {
		return supportedChannel;
	}

    public void setSupportedChannel(List<string> supportedChannel)
    {
		this.supportedChannel = supportedChannel;
	}

	public string getOwnerId() {
		return ownerId;
	}

	public void setOwnerId(string ownerId) {
		this.ownerId = ownerId;
	}

	public string getId() {
		return id;
	}

	

	public void setId(string id) {
		this.id = id;
	}



    Dictionary<string, DeviceComponent> components = new Dictionary<string, DeviceComponent>();

    public Dictionary<string, DeviceComponent> getComponents()
    {
		return components;
	}
    public void setComponents(Dictionary<string, DeviceComponent> components)
    {
		this.components = components;
	}

	
	public GeneralDevice() {

		
	}

	public string tostring() {
		// TODO Auto-generated method stub
		string r = "id: " + this.id;
		if(components != null){
		foreach(string k in components.Keys){
			r += " " + components[k].getComponentType() + " " + k + " : " + components[k].getCurrentStatus();
		}
		}
		return r;
	}

	public DeviceStatus getStatus(){
		DeviceStatus stat = new DeviceStatus();
		stat.setDeviceId(id);
		foreach(DeviceComponent dc in components.Values){
			string v =  dc.getCurrentStatus();
			
			stat.getValues().Add(new StatusItem(dc.getLocalId(),v));
		}
		return stat;
		
	}

	public Dictionary<string, string> getStatusMap(){
        Dictionary<string, string> rst = new Dictionary<string, string>();
		foreach(DeviceComponent dc in components.Values){
			string v =  dc.getCurrentStatus();
			rst.Add(dc.getLocalId(), dc.getCurrentStatus());
		}
		return rst;
		
	}
    public void setStatusMap(Dictionary<string, string> vs)
    {

	foreach(string key in vs.Keys){
		string v = vs[key];
		DeviceComponent dc = getComponents()[key];
		dc.setCurrentStatus(v);
		
	}
		
	}
	DeviceComponent[] deviceComponents;
	string channel;
	
	public void componentId(){
		foreach(DeviceComponent d in components.Values)
			d.setId(id + "_" + d.getLocalId());
	}
}
	
   
}
